package com.kitty.game.task.service.taskHandler;

import com.kitty.game.config.NPC;
import com.kitty.game.config.TaskSet;
import com.kitty.game.role.model.Role;
import com.kitty.game.task.TaskDataPool;
import com.kitty.game.task.model.product.TaskType;
import org.springframework.stereotype.Component;

@Component
public class ChengXianTaskHandler extends TaskHandler {
    private int minLevel = 130;

    @Override
    public boolean resetTask(Role role, TaskSet taskSet) {
        /**阵营任务不能重置*/
        return false;
    }

    @Override
    public TaskType getTaskType() {
        return TaskType.CHENG_XIAN_ZHI_LU;
    }

    @Override
    public String getTaskButtons(Role role, NPC npc) {
        /**满足以下条件时，需要显示成仙之路任务按钮
         *  1. 角色等级大于等于130
         *  2. 角色完成大飞任务
         */
        if (role.getLevel() >= minLevel) {
            return "";
        }

        TaskSet taskSet = taskService.getTaskSet(TaskDataPool.CHENG_XIAN_ZHI_LU, role);
        return taskSet.getButtton();
    }

    @Override
    public boolean acceptTask(Role role, TaskSet taskSet) {
        if (!canAcceptTask(role, taskSet)) {
            return false;
        }

        doBeforeAccept(role, taskSet);

        doAcceptTask(role, taskSet);

        doAfterAccept(role, taskSet);

        return true;
    }

    @Override
    public void doBeforeAccept(Role role, TaskSet taskSet) {

    }
}
